CreateFrontEndObject
creates a reference to the inner expression and stores it into frontend objects storage as JSON expression shared with Kernel and Notebook
CreateFrontEndObject[expr_, id_String | Null, opts___Rule] _FrontEndExecutable
Returns FrontEndExecutable
object with a given id
or generated.
See more about it in WLJS Functions
Is used to force Wolfram Kernel to execute an expression on the frontend (WLJS / browser's side) with an HTML element provided if needed for showing the data.
This is a fundamental component for Graphics
, InputRange
... and other interactive elements. Event EventObject
that comes from event-generators use it to show the UI element.
In general, containers is a huge fundamental building blocks for almost everything.
If you do not want to apply CreateFrontEndObject on your symbol manually, consider to define MakeBoxes for StandardForm. Then it can be applied automatically once it goes to the output cell.
Options
"Store"
Specifies which to storage to use for an expression ("Frontend"
, "Kernel"
, or All
). The default values is All
.
Each time you create Graphics
or any other frontend object, it makes two copies of it: the first one is shared with a browser (WLJS), while the second one is a private copy used by Wolfram Kernel once fetched by FrontEndRef or evaluated for a second time (see ViewBox).
Applications
For Graphics
, InputButton
and etc CreateFrontEndObject is applied automatically, once it is converted to a StandardForm on output.
Custom WLJS function inside a container
Use for custom defined WLJS functions i.e.
.js
core.MyCustomStuff = async (args, env) => {
env.element.innerText = "Hi dude!";
}
and then in the next cell
CreateFrontEndObject[MyCustomStuff[]]
Use TagSetDelayed
on MakeBoxes to skip this procedure, i.e.
MyCustomStuff /: MakeBoxes[m_MyCustomStuff, StandardForm] := With[{
o = CreateFrontEndObject[m]
},
MakeBoxes[m, StandardForm]
]
then you don't need to manually create a frontend object anymore.